<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<link type="text/css" rel="stylesheet"
	href="/products/passport/v2/css/register.css" />
<link type="text/css" rel="stylesheet"
	href="/products/passport/v2/css/base.css" />
<style>
.regter_main .bd {
	margin-top: 0
}
</style>
<%@ include file="head.jsp"%>
<script type="text/javascript">
	var userInfo = "";
</script>
<body style="min-width: 980px; min-height: 850px;">
	<div style="height: 65%;width: 100%;">
		<!--主内容-->
		<div class="regter_main">
			<div class="hd_prog">
				<h2 class="h2_tit" id="title" style="padding-left: 20%">请输入您要找回密码的账号</h2>
			</div>
			<div class="bd" id="checkAcc">
				<div class="t_line">
					<div class="l_list wone_zc1">乐控科技账号：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="useraccount" maxlength="30" name="user" type="text">
						</div>
						<div id="useraccountTip"></div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">验证码：</div>
					<div class="r_list wtwo_zc1">
						<input id="verif_code" maxlength="4" type="text" class="vali_text"
							kztype="captcha">
						<div id="verif_codeTip"></div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="submit_first_btn" class="btn_10"> <span class="btn_psd">下一步</span></a>
					</div>
				</div>
			</div>
			<div class="bd" id="selectType" style="display: none">
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a class="btn_10" id="passwordBackByPhone"> <span
							style="width: 280px;" class="btn_psd">通过验证密保手机找回密码</span></a>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="passwordBackByEmail" class="btn_10"> <span
							style="width: 280px;" class="btn_psd">通过验证密保邮箱找回密码</span></a>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a class="btn_10" id="passwordBackByQuestion"> <span
							style="width: 280px;" class="btn_psd">通过验证密保问题找回密码</span></a>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a class="btn_10" id="realNameInfoBtn"> <span
							style="width: 280px;" class="btn_psd">通过实名信息找回密码</span></a>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a class="btn_10" id="normalComplaintBtn"> <span
							style="width: 280px;" class="btn_psd">通过申述找回密码</span></a>
					</div>
				</div>
			</div>
			<div class="bd" id="checkQuestion" style="display: none">
				<div id="questionDiv1">
					<div class="t_line">
						<div class="l_list wone_zc1">密保问题1：</div>
						<div id="question1" class="r_list wtwo_zc1"
							style="width:253px;height:34px;display:inline-block;float:left;line-height: 30px;">
							<div></div>
						</div>
					</div>
					<div class="t_line">
						<div class="l_list wone_zc1">&nbsp;</div>
						<div class="r_list wtwo_zc1">
							<div class="input_text">
								<input id="answer1" maxlength="30" name="user" type="text">
							</div>
							<div id="useraccountTip"></div>
						</div>
					</div>
				</div>
				<div id="questionDiv2">
					<div class="t_line">
						<div class="l_list wone_zc1">密保问题2：</div>
						<div id="question2" class="r_list wtwo_zc1"
							style="width:253px;height:34px;display:inline-block;float:left;line-height: 30px;">
							<div></div>
						</div>
					</div>
					<div class="t_line">
						<div class="l_list wone_zc1">&nbsp;</div>
						<div class="r_list wtwo_zc1">
							<div class="input_text">
								<input id="answer2" maxlength="30" name="user" type="text">
							</div>
							<div id="useraccountTip"></div>
						</div>
					</div>
				</div>
				<div id="questionDiv3">
					<div class="t_line">
						<div class="l_list wone_zc1">密保问题3：</div>
						<div id="question3" class="r_list wtwo_zc1"
							style="width:253px;height:34px;display:inline-block;float:left;line-height: 30px;">
							<div></div>
						</div>
					</div>
					<div class="t_line">
						<div class="l_list wone_zc1">&nbsp;</div>
						<div class="r_list wtwo_zc1">
							<div class="input_text">
								<input id="answer3" maxlength="30" name="user" type="text">
							</div>
							<div id="useraccountTip"></div>
						</div>
					</div>
					<div class="t_line">
						<div class="l_list wone_zc1">&nbsp;</div>
						<div class="r_list wtwo_zc1">
							<a id="checkAnswer" class="btn_10"> <span class="btn_psd">下一步</span></a>
						</div>
					</div>
				</div>
			</div>
			<div class="bd" id="noQuestion" style="display: none">
				<div class="l_list wone_zc1" style="color: red;font-size: 20px;">您尚未设置密保信息!</div>
			</div>
			<div class="bd" id="noMail" style="display: none">
				<div class="l_list wone_zc1" style="color: red;font-size: 20px;">您尚未设置密保邮箱!</div>
			</div>
			<div class="bd" id="noPhone" style="display: none">
				<div class="l_list wone_zc1" style="color: red;font-size: 20px;">您尚未设置密保手机!</div>
			</div>
			<div class="bd" id="answerError" style="display: none">
				<div class="l_list wone_zc1" style="color: red;font-size: 20px;">密保答案错误!</div>
			</div>
			<div class="bd" id="realNameError" style="display: none">
				<div class="l_list wone_zc1" style="color: red;font-size: 20px;">身份信息验证失败!</div>
			</div>
			<div class="bd" id="complaintInfo" style="display: none">
				<div class="l_list wone_zc1"
					style="color: green;font-size: 20px;width: 100%;text-align: center;"
					id="complaintInfoMsg">您的申诉信息已受理,工作人员会在48小时内与您取得联系</div>
			</div>
			<div class="bd" id="setNewPwd" style="display: none">
				<div class="t_line">
					<div class="l_list wone_zc1">新密码：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="newPwd" maxlength="30" name="newPwd" type="password">
						</div>
						<div id="newPwdTip"></div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">重复新密码：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="newPwdRep" maxlength="30" name="newPwdRep"
								type="password">
						</div>
						<div id="newPwdRepTip"></div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="setNewPwdCfr" class="btn_10"> <span class="btn_psd">确认</span></a>
					</div>
				</div>
			</div>
			<div class="bd" id="sendEmailCode" style="display: none">
				<div class="t_line">
					<div style="font-size: 14px;" id="sendEmailCodeText">已向您的邮箱发送了验证码,请输入收到的验证码：</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">验证码：</div>
					<div class="r_list wtwo_zc1" style="width: 253px;">
						<div class="input_text">
							<input id="emailCode" maxlength="36" name="user" type="text"
								style="width: 253px;;">
						</div>
						<div id="emailCodeTip"></div>
					</div>
				</div>

				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="pwdBackByEmail" class="btn_10"> <span class="btn_psd">下一步</span></a>
					</div>
				</div>
			</div>


			<div class="bd" id="sendPhoneCode" style="display: none">
				<div class="t_line">
					<div style="font-size: 14px;" id="sendPhoneCodeText">已向您的手机发送了验证码,请输入收到的验证码：</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">验证码：</div>
					<div class="r_list wtwo_zc1" style="width: 253px;">
						<div class="input_text">
							<input id="phoneCode" maxlength="36" name="user" type="text"
								style="width: 253px;;">
						</div>
						<div id="phoneCodeTip"></div>
					</div>
				</div>

				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="pwdBackByPhone" class="btn_10"> <span class="btn_psd">下一步</span></a>
					</div>
				</div>
			</div>

			<div class="bd" id="emailCodeError" style="display: none">
				<div class="l_list wone_zc1" style="color: red;font-size: 20px;">邮件验证码错误!</div>
			</div>
			<div class="bd" id="realNameInfoView" style="display: none">
				<div class="t_line">
					<div class="l_list wone_zc1">您的姓名：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="realName" maxlength="30" name="realName" type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">您的身份证号码：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="idCard" maxlength="30" name="idCard" type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="realNameInfoSub" class="btn_10"> <span class="btn_psd">下一步</span></a>
					</div>
				</div>
			</div>
			<div class="bd" id="realNameSuccess" style="display: none">
				<div class="t_line">
					<div class="l_list wone_zc1">您的联系方式：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="realNameContact" maxlength="200"
								name="realNameContact" type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="realNameSuccessSub" class="btn_10"> <span
							class="btn_psd">点击发送申诉单</span></a>
					</div>
				</div>
			</div>
			<div class="bd" id="normalComplaintView" style="display: none">
				<div class="t_line">
					<div class="l_list wone_zc1">您的姓名：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="realNameNormal" maxlength="30" name="realNameNormal"
								type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">您的身份证号码：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="idCardNormal" maxlength="30" name="idCardNormal"
								type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">您的联系方式：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="contactNormal" maxlength="30" name="idCardNormal"
								type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">您的申诉信息：</div>
					<div class="r_list wtwo_zc1">
						<div class="input_text">
							<input id="normalComplaintInfo" maxlength="100"
								name="normalComplaintInfo" type="text">
						</div>
					</div>
				</div>
				<div class="t_line">
					<div class="l_list wone_zc1">&nbsp;</div>
					<div class="r_list wtwo_zc1">
						<a id="normalComplaintSub" class="btn_10"> <span
							class="btn_psd">提交申诉单</span></a>
					</div>
				</div>
			</div>
		</div>
	</div>
<%@ include file="footer.jsp"%>
</body>
<script src="/products/passport/v2/js/jquery.js"></script>
<script type="text/javascript"
	src="/products/passport/v2/js/kzpassport.js"></script>
<script type="text/javascript"
	src="/products/passport/v2/js/formValidator413.js"></script>
<script type="text/javascript">
	var countdown = 60;
	function settime(val) {
		if (countdown == 0) {
			val.removeAttribute("disabled");
			val.value = "免费获取验证码";
			countdown = 60;
		} else {
			val.setAttribute("disabled", true);
			val.value = "重新发送(" + countdown + ")";
			countdown--;
		}
		setTimeout(function() {
			settime(val);
		}, 1000);
	}

	$(document).ready(function() {
		$("#selectType").hide();
		$("#checkQuestion").hide();
		$("#noQuestion").hide();
		$("#answerError").hide();
		$("#setNewPwd").hide();
		$("#sendEmailCode").hide();
		$("#emailCodeError").hide();
		$("#realNameInfoView").hide();
		$("#realNameError").hide();
		$("#realNameSuccess").hide();
		$("#complaintInfo").hide();
		$("#normalComplaintView").hide();
		$("#noMail").hide();
		$("#sendPhoneCode").hide();
		$("#noPhone").hide();
	});

	$.formValidator.initConfig({
		errorFocus : false,
		formID : "fpwduserinfo_frm",
		submitOnce : true,
		forcevalid : false,
		errorfocus : false,
		validatorGroup : "findpwd_userinfo"
	});
	$("#useraccount").formValidator({
		validatorGroup : "findpwd_userinfo",
		onFocus : tips.account.f_find
	}).regexValidator({
		regExp : "useraccount",
		dataType : "enum",
		onError : tips.account.err,
		onErrorEmpty : tips.account.err_null
	}).ajaxValidator({
		url : "/products/checkuser",
		dataType : "json",
		async : false,
		data : {
			"useraccount" : function() {
				return $("#useraccount").val();
			}
		},
		success : function(data) {
			if (data.code != "0") {
				return "您填写的账号不存在";
			}
			userInfo = data;
			userInfo.userAccount = $("#useraccount").val();
			return true;
		},
		onError : "您填写的账号不存在"
	});
	$("#verif_code").formValidator({
		validatorGroup : "findpwd_userinfo",
		onFocus : tips.captcha.f
	}).inputValidator({
		min : 4,
		max : 4,
		onError : tips.captcha.err,
		onErrorEmpty : tips.captcha.err_null
	}).ajaxValidator({
		url : "/products/checkVCode?codeType=passwordBack",
		dataType : "json",
		type : "get",
		async : true,
		data : {
			"code" : function() {
				return $("#verif_code").val();
			}
		},
		success : function(data) {
			if (data != "1") {
				return tips.captcha.err;
			}
			return true;
		},
		onError : tips.captcha.err
	});

	$.formValidator.initConfig({
		errorFocus : false,
		formID : "fpwduserinfo_frm",
		submitOnce : true,
		forcevalid : false,
		errorfocus : false,
		validatorGroup : "findpwd_userinfoPwd"
	});
	$("#newPwd").formValidator({
		validatorGroup : "findpwd_userinfoPwd",
		onFocus : tips.pwd.f_find
	}).regexValidator({
		regExp : "pwd",
		dataType : "enum",
		onError : tips.pwd.err,
		onErrorEmpty : tips.pwd.err_null
	});
	$("#newPwdRep").formValidator({
		validatorGroup : "findpwd_userinfoPwd",
		onFocus : tips.rpwd.f_find
	}).compareValidator({
		desID : "newPwd",
		operateor : "=",
		onError : tips.rpwd.err
	});
	$("#submit_first_btn").bind("click", function() {
		if (!$.formValidator.pageIsValid("findpwd_userinfo")) {
			return;
		}
		$("#checkAcc").hide();
		$("#selectType").show();
		$("#title").text("请选择密码找回方式");
	});
	$("#passwordBackByQuestion").click(
			function() {
				if (userInfo.object.question1 == ""
						&& userInfo.object.question2 == ""
						&& userInfo.object.question3 == "") {
					$("#selectType").hide();
					$("#title").text("您尚未设置密保信息");
					$("#noQuestion").show();
				} else {
					$("#title").text("请输入密保答案");
					$("#checkQuestion").show();
					$("#selectType").hide();
					if (userInfo.object.question1 == ""||userInfo.object.question1==null) {
						$("#questionDiv1").hide();
					}
					if (userInfo.object.question2 == ""||userInfo.object.question2==null) {
						$("#questionDiv2").hide();
					}
					if (userInfo.object.question3 == ""||userInfo.object.question3==null) {
						$("#questionDiv3").hide();
					}
					$("#question1").html(userInfo.object.question1);
					$("#question2").html(userInfo.object.question2);
					$("#question3").html(userInfo.object.question3);
				}
			});
	$("#checkAnswer").click(function() {
		$.ajax({
			url : "/products/checkanswer",
			async : false,
			cache : false,
			data : {
				"userAccount" : userInfo.userAccount,
				"answer1" : $("#answer1").val(),
				"answer2" : $("#answer2").val(),
				"answer3" : $("#answer3").val()
			},
			dataType : "text",
			type : "post",
			success : function(data) {
				if ("success" == data) {
					$("#checkQuestion").hide();
					$("#setNewPwd").show();
				}
				if ("error" == data) {
					$("#checkQuestion").hide();
					$("#answerError").show();
				}
			} // 回调函数
		});
	});
	$("#setNewPwdCfr").bind("click", function() {
		if (!$.formValidator.pageIsValid("findpwd_userinfoPwd")) {
			return;
		}
		$.ajax({
			url : "/products/setnewpwdcfr",
			async : false,
			cache : false,
			data : {
				"accName" : userInfo.userAccount,
				"newPwd" : $("#newPwdRep").val()
			},
			dataType : "text",
			type : "post",
			success : function(data) {
				window.open("/products/login","_self");
			} // 回调函数
		});
	});
	$("#passwordBackByEmail").click(
			function() {
				if (userInfo.object.email == ""||userInfo.object.email == null) {
					$("#selectType").hide();
					$("#noMail").show();
					$("#title").text("您尚未设置密保邮箱");
					return;
				}
				;
				$.ajax({
					url : "/products/passwordBackByEmail",
					async : false,
					cache : false,
					data : {
						"userAccount" : userInfo.userAccount,
						"email" : userInfo.object.email
					},
					dataType : "text",
					type : "post"
				});
				$("#sendEmailCode").show();
				$("#selectType").hide();
				$("#sendEmailCodeText").html(
						"已向您(" + userInfo.object.email + ")发送了验证邮件,请输入收到的验证码");
				$("#title").text("请输入收到的验证码");
			});
	$("#pwdBackByEmail").click(function() {
		$.ajax({
			url : "/products/checkEmailCode",
			async : false,
			cache : false,
			data : {
				"userAccount" : userInfo.userAccount,
				"emailCode" : $("#emailCode").val()
			},
			dataType : "text",
			type : "post",
			success : function(msg) {
				if ("success" == msg) {
					$("#sendEmailCode").hide();
					$("#setNewPwd").show();
					$("#title").text("请牢记新密码");
				}
				if ("error" == msg) {
					$("#sendEmailCode").hide();
					$("#emailCodeError").show();
					$("#title").text("请重试");
				}
			}
		});
	});
	$("#pwdBackByPhone").click(function() {
		$.ajax({
			url : "/products/checksmscode",
			async : false,
			cache : false,
			data : {
				"type" : "pwdPhoneBack",
				"code" : $("#phoneCode").val()
			},
			dataType : "text",
			type : "post",
			success : function(msg) {
				$("#sendPhoneCode").hide();
				if (1 == msg) {
					$("#sendEmailCode").hide();
					$("#setNewPwd").show();
					$("#title").text("请牢记新密码");
				}
				if (-1 == msg) {
					$("#sendEmailCode").hide();
					$("#emailCodeError").show();
					$("#title").text("请重试");
				}
			}
		});
	});
	$("#realNameInfoBtn").click(function() {
		$("#selectType").hide();
		$("#title").html("请输入您的身份证信息");
		$("#realNameInfoView").show();
	});
	$("#realNameInfoSub").click(function() {
		$.ajax({
			url : "/products/realNameInfoSub",
			async : false,
			cache : false,
			data : {
				"realName" : $("#realName").val(),
				"idCard" : $("#idCard").val()
			},
			dataType : "text",
			type : "post",
			success : function(data) {
				if ("success" == data) {
					$("#realNameInfoView").hide();
					$("#realNameSuccess").show();
					$("#title").html("请发起申诉单");
				}
				if ("error" == data) {
					$("#realNameInfoView").hide();
					$("#realNameError").show();
					$("#title").html("请重试");
				}
			} // 回调函数
		});
	});
	$("#realNameInfoSub").click(function() {
		$.ajax({
			url : "/products/realNameSuccessSub",
			async : false,
			cache : false,
			data : {
				"realName" : $("#realName").val(),
			},
			dataType : "text",
			type : "post",
			success : function(data) {
				if ("success" == data) {
					$("#realNameInfoView").hide();
					$("#realNameSuccess").show();
					$("#title").html("发送申诉单");
				}
				if ("error" == data) {
					$("#realNameInfoView").hide();
					$("#realNameError").show();
					$("#title").html("请重试");
				}
			} // 回调函数
		});
	});

	$("#realNameSuccessSub").click(function() {
		if ($.trim($("#realNameContact").val()) == "") {
			alert("联系方式不能为空");
			return;
		}
		$("#title").html("申诉成功");
		$("#realNameSuccess").hide();
		$("#complaintInfo").show();
		$.ajax({
			url : "/products/sendComplaint",
			async : true,
			cache : false,
			data : {
				"realNameContact" : $("#realNameContact").val(),
				"userAccount" : userInfo.userAccount,
				"realName" : $("#realName").val(),
				"idCard" : $("#idCard").val(),
				"flagTrueNameCheck" : 1,
				"normalComplaintInfo" : ""
			},
			type : "post",
			dataType : "text"
		});
	});
	$("#normalComplaintBtn").click(function() {
		$("#title").val("请提交申诉单");
		$("#selectType").hide();
		$("#normalComplaintView").show();
	});
	$("#normalComplaintSub").click(function() {
		if ($.trim($("#realNameNormal").val()) == "") {
			alert("姓名不能为空");
			return;
		}
		if ($.trim($("#idCardNormal").val()) == "") {
			alert("身份证号码不能为空");
			return;
		}
		if ($.trim($("#contactNormal").val()) == "") {
			alert("联系方式不能为空");
			return;
		}
		if ($.trim($("#normalComplaintInfo").val()) == "") {
			alert("申诉信息不能为空");
			return;
		}
		$("#title").html("申诉成功");
		$("#normalComplaintView").hide();
		$("#complaintInfoMsg").text("您的申诉信息已受理,工作人员会在7个工作日内与您取得联系");
		$("#complaintInfo").show();
		$.ajax({
			url : "/products/sendComplaint",
			async : true,
			cache : false,
			data : {
				"realNameContact" : $("#contactNormal").val(),
				"userAccount" : userInfo.userAccount,
				"realName" : $("#realNameNormal").val(),
				"idCard" : $("#idCardNormal").val(),
				"flagTrueNameCheck" : 2,
				"normalComplaintInfo" : $("#normalComplaintInfo").val(),
			},
			type : "post",
			dataType : "text"
		});
	});
	$("#passwordBackByPhone").click(
			function() {debugger;
				if (userInfo.object.phone == ""||userInfo.object.phone == null) {
					$("#selectType").hide();
					$("#noPhone").show();
					$("#title").text("您尚未设置密保手机");
					return;
				}
				;
				$.ajax({
					url : "/products/regsmscode",
					async : false,
					cache : false,
					data : {
						"type" : 3,
						"phone" : userInfo.object.phone
					},
					dataType : "text",
					type : "post"
				});
				$("#sendPhoneCode").show();
				$("#selectType").hide();
				$("#sendPhoneCodeText").html(
						"已向您(" + userInfo.object.phone + ")发送了验证短信,请输入收到的验证码");
				$("#title").text("请输入收到的验证码");
			});
</script>

</html>
